From 47a86a1a20b6289cfe11d993e0f381b6b5970449 Mon Sep 17 00:00:00 2001 From: Ell Date: Sun, 24 Sep 2017 13:43:02 -0400 Subject: [PATCH] babl: avoid negative degree when shrinking a zero polynomial When shrinking a zero polynomial, avoid trying to set its degree to a negative value, and just keep it at 0, which is the minimal degree we support. Note that this also happens for polynomials whose coefficients are all NaN, as is the case in bug 788093, so they also become zero polynomials after shrinking, incidentally. --- babl/babl-polynomial.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/babl/babl-polynomial.c b/babl/babl-polynomial.c index d51685d..c9f195b 100644 --- a/babl/babl-polynomial.c +++ b/babl/babl-polynomial.c @@ -190,7 +190,11 @@ babl_polynomial_shrink (BablPolynomial *poly) break; } - if (i > 0) + if (i == poly->degree + 1) + { + babl_polynomial_reset (poly, poly->scale); + } + else if (i > 0) { memmove (poly->coeff, &poly->coeff[i], (poly->degree - i + 1) * sizeof (double)); -- 2.30.2